package com.ruoyi.gwc.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SnowFlakeIDGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.gwc.mapper.TApprovalRepairMapper;
import com.ruoyi.gwc.domain.TApprovalRepair;
import com.ruoyi.gwc.service.ITApprovalRepairService;

import static com.ruoyi.common.utils.SecurityUtils.getUsername;

/**
 * 申请维修审批Service业务层处理
 * 
 * @author wp
 * @date 2024-12-13
 */
@Service
public class TApprovalRepairServiceImpl extends ServiceImpl<TApprovalRepairMapper, TApprovalRepair> implements ITApprovalRepairService
{
    @Autowired
    private TApprovalRepairMapper tApprovalRepairMapper;

    /**
     * 查询申请维修审批
     * 
     * @param approvalId 申请维修审批主键
     * @return 申请维修审批
     */
    @Override
    public TApprovalRepair selectTApprovalRepairByApprovalId(Long approvalId)
    {
        return tApprovalRepairMapper.selectTApprovalRepairByApprovalId(approvalId);
    }

    /**
     * 查询申请维修审批列表
     * 
     * @param tApprovalRepair 申请维修审批
     * @return 申请维修审批
     */
    @Override
    public List<TApprovalRepair> selectTApprovalRepairList(TApprovalRepair tApprovalRepair)
    {
        return tApprovalRepairMapper.selectTApprovalRepairList(tApprovalRepair);
    }

    /**
     * 新增申请维修审批
     * 
     * @param tApprovalRepair 申请维修审批
     * @return 结果
     */
    @Override
    public int insertTApprovalRepair(TApprovalRepair tApprovalRepair)
    {
        tApprovalRepair.setCreateTime(DateUtils.getNowDate());
        tApprovalRepair.setCreateBy(getUsername());
        tApprovalRepair.setApprovalId(SnowFlakeIDGenerator.getInstance().nextId());
        return tApprovalRepairMapper.insertTApprovalRepair(tApprovalRepair);
    }

    /**
     * 修改申请维修审批
     * 
     * @param tApprovalRepair 申请维修审批
     * @return 结果
     */
    @Override
    public int updateTApprovalRepair(TApprovalRepair tApprovalRepair)
    {
        return tApprovalRepairMapper.updateTApprovalRepair(tApprovalRepair);
    }

    /**
     * 批量删除申请维修审批
     * 
     * @param approvalIds 需要删除的申请维修审批主键
     * @return 结果
     */
    @Override
    public int deleteTApprovalRepairByApprovalIds(Long[] approvalIds)
    {
        return tApprovalRepairMapper.deleteTApprovalRepairByApprovalIds(approvalIds);
    }

    /**
     * 删除申请维修审批信息
     * 
     * @param approvalId 申请维修审批主键
     * @return 结果
     */
    @Override
    public int deleteTApprovalRepairByApprovalId(Long approvalId)
    {
        return tApprovalRepairMapper.deleteTApprovalRepairByApprovalId(approvalId);
    }
}
